function ajax(o){if(!o.url){alert('URL not defined');return false;};try{ this.xmlhttp = new XMLHttpRequest();}catch(ee){ try{ this.xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); }catch(eee){ try{ this.xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); }catch(E){this.xmlhttp = false; }; };};this.json = (o.json != undefined) ? o.json : true;this.url = (o.url) ? o.url : null;this.serialize = (o.serialize) ? o.serialize : null;this.method = (o.method) ? o.method.toUpperCase() : 'POST';this.debug = (o.debug) ? o.debug : false;this.results = null;this.extra = (o.extra) ? o.extra: null;this.timeout = ((o.timeout) ? o.timeout : 60) * 1000;this.encrypt = (o.encrypt == '') ? o.encrypt : true;this.parameters = (o.parameters) ? o.parameters : {};this._parameters = '';this._timer;_this = this;this._64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';this._e = function(_77){var i = 0;var _70 = new String('');var _71, _72, _73;var _74, _75, _76, _79;while (i < _77.length) {_71 = _77.charCodeAt(i++);_72 = _77.charCodeAt(i++);_73 = _77.charCodeAt(i++);_74 = _71 >> 2;_75 = ((_71 & 3) << 4) | (_72 >> 4);_76 = ((_72 & 15) << 2) | (_73 >> 6);_79 = _73 & 63;if(isNaN(_72)) _76 = _79 = 64;else if(isNaN(_73)) _79 = 64;_70 += this._64.charAt(_74)+this._64.charAt(_75);_70 += this._64.charAt(_76)+this._64.charAt(_79);};return _70;};this._serialize = function(f){var f = (typeof (f) == 'object') ? f : gElm(f);var ae = f.getElementsByTagName('input');var at = f.getElementsByTagName('textarea');var as = f.getElementsByTagName('select');var e = Array();var q = 0;while(q<ae.length){ if(ae[q].type != 'button' && ae[q].type != 'reset' && ae[q].type != 'image' && ae[q].type != 'submit' && ae[q].type != 'file'){if(ae[q].type == 'radio'){ if(ae[q].checked) e.push(ae[q]);} else if(ae[q].type == 'checkbox'){if(ae[q].checked == true) e.push(ae[q]);} else {e[e.length] = (ae[q]);};};q++;};var m=0;while(m<as.length){if(as[m].selectedIndex != -1){e[e.length] = (as[m]);};m++;};var j=0;while(j<at.length){e[e.length] = (at[j]);j++;};var k=0;while(k<e.length){this.parameters[e[k].name] = e[k].value;k++;};};if(this.serialize) this._serialize(this.serialize);for(a in this.parameters){this._parameters += a + '=' + ((this.encrypt && !this.debug) ? this._e(escape(this.parameters[a].toString())) : escape(this.parameters[a].toString())) + '&';};this._parameters += '&cacheBuster='+new Date().getTime();if (this.debug) alert('DEBUG\nurl: ' + this.url + '\nparameters: ' + this._parameters + '\nmethod: ' + this.method);this._snd = function(xmlhttp, extra, timeout, timer){try{this.onInit = (o.onInit) ? o.onInit(extra) : null;timer = setTimeout(function(){xmlhttp.abort();if(o.onTimeout){o.onTimeout(extra);} else{alert('Não foi possível enviar sua requisição.\nTempo de conexão excedida.');}return false;}, timeout); xmlhttp.onreadystatechange = function(){if(xmlhttp.readyState == 4 ){if(!xmlhttp.responseText){return false;}clearTimeout(timer);this.results = (_this.json) ? eval(xmlhttp.responseText) : xmlhttp.responseText;(o.onFinish) ? o.onFinish(this.results, extra): null;};};if(this.method == 'POST') {xmlhttp.open(this.method, this.url, true);xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttp.send(this._parameters);} else {xmlhttp.open(this.method, this.url + '?' + this._parameters, true); xmlhttp.send(null);};} catch (err){(o.onError) ? o.onError(this.results, this.extra) : function(){alert('Erro durante o envio.\n'+err+'\nPor favor tente novamente.');return false;};return false;};};this._snd(this.xmlhttp, this.extra, this.timeout, this._timer);};ajaxRun = function(o){new ajax(o);};var include = function($url, $obj){$obj = typeof($obj) == 'object' ? $obj : {};var onInit = typeof($obj.onInit) == 'function' ? $obj.onInit : null;var onError = typeof($obj.onError) == 'function' ? $obj.onError : null;var onFinish = typeof($obj.onFinish) == 'function' ? $obj.onFinish : null;if(onInit)onInit();var req = false;if (window.XMLHttpRequest) {try {req = new XMLHttpRequest;} catch (e) {req = false;}} else if (window.ActiveXObject) {try {req = new ActiveXObject("Msxml2.XMLHTTP");} catch (ee) {try {req = new ActiveXObject("Microsoft.XMLHTTP");} catch (eee) {req = false;}}}if (req) {req.open("GET", $url, false);req.send(null);if(onFinish)onFinish(req.responseText);return req.responseText;} else {if(onError){onError();}else{alert("Unable to load include file: " + u);}}};;var _arrTweener = [];var Tweener = function(){var obj = null;var end = null;var prop = null;var unit = null;var _interval = 0;this.onComplete = undefined;this.onInit = undefined;this.onUpdate = undefined;this.isRunning = false; this.speed = 2.9; this.run = function($obj, $end, $prop, $unit){if(this.isRunning) return;obj = typeof($obj) == 'string' ? $($obj) : $obj; end = $end;prop = $prop;unit = $unit;if(!obj) return alert('ERROR Slider.run: $obj not defined');if(end == undefined || isNaN(end)) return alert('ERROR Slider.run: $end not defined');if(!prop) return alert('ERROR Slider.run: $prop not defined');if(!unit) return alert('ERROR Slider.run: $unit not defined');var _this = this;if(this.onInit) this.onInit(obj, parseInt(obj.style[prop]) || 0);_arrTweener.push(this);_interval = setInterval(function(){_this.isRunning = true;var current = parseInt(obj.style[prop]) || 0;var v = _easing(current, end, _this.speed);if(v === false){v = end;_posObj(v);_this.stop();if(_this.onComplete) _this.onComplete(obj, end);}_posObj(v);}, 100);};this.stopAllTweens = function(){for(var i=0; i<_arrTweener.length; i++){_arrTweener[i].stop();}};this.stop = function(){this.isRunning = false;clearInterval(_interval);_removemeFrom_arrTweener(this);};function _removemeFrom_arrTweener($me){for(i=0; i<_arrTweener.length; i++){if($me == _arrTweener[i]) _arrTweener.splice(i, 1);}}function _posObj($v){obj.style[prop] = $v + unit;if(this.onUpdate) this.onUpdate(obj, $v);}function _easing($ini,$end,$speed){var c = Math.round($ini+=($end-$ini)/$speed);if(Math.abs(c - end) <= 2.5) return false;return c;}};var SpeedTest = {speed: undefined,run: function(){var startTime = new Date() ;createElm(false,['div', {id: 'divSpeedTest', 'style':'position:absolute;top:-10000px;left:-10000px;'},'']);for( var i = 0; i <= 2000; i++ ) {$('divSpeedTest').style.left = (-i) + 'px';$('divSpeedTest').style.top = (-i) + 'px';}delElm('divSpeedTest');var endTime = new Date();return this.speed = (endTime - startTime);},runOnce: function(){if(this.speed) return this.speed;else return this.run();}};;var HomeWindow = {arrCategories: null,arrCategoriesElements: [],imgCategoryPrefix: url_global + '/Imagens/mn_wdw_',imgCategorySufix: '.gif',idCategoria: null,idProd: null,fetch:function($url){$('windowContainer').innerHTML = '<ul id="wdwCategoryLst"> <li class="off"> <b class="tl">&nbsp;</b> <a href="javascript:;"> <img src="'+ url_global +'/Imagens/px.gif" alt="" title="" /> </a> <b class="tr">&nbsp;</b> </li> </ul> <div class="lstContainerBorder" id="wdwCategoryLstProducts"> <div class="lstContainer"> <a class="setaLeft" href="javascript:;"> <img src="'+ url_global +'/Imagens/bt_wdw_left.gif" alt="anterior" title="" /> </a> <div class="lstMask"> <ul class="lstProducts prodBlue"> <li> <p class="photo"><img src="'+ url_global +'/Imagens/px.gif" alt="" title="" /></p> <p class="prodTit"> <a href="'+ url_global +'"><strong></strong></a> </p> <p class="prodPriceFrom"> De: <strike></strike> </p> <p class="prodPriceTo"> Por: R$ </p> <p class="prodPriceDiv"> </p> </li> </ul> </div> <a class="setaRight" href="javascript:;"> <img src="'+ url_global +'/Imagens/bt_wdw_right.gif" alt="próximo" title="" /> </a> </div><br class="cb" /> </div>';$('windowContainer').className = 'windowContainer';HomeWindow._create();},setCategoryList:function($obj){this.arrCategories = $obj;},_create: function(){ProductsWindow.init();var arr = this.arrCategories.categories;var menu = gTag('li', $('wdwCategoryLst'))[0];var cloneMenu = menu.cloneNode(true);delElm(menu);var newMenu, a, img, li, n, initCat;for(var i=0; i<arr.length; i++){newMenu = cloneMenu.cloneNode(true);a = gTag('a', newMenu)[0];img = gTag('img', a)[0];img.alt = img.title = arr[i].name;img.src = this.imgCategoryPrefix + arr[i].img + '_off' + this.imgCategorySufix;pImg(img.src);pImg(this.imgCategoryPrefix + arr[i].img + '_on' + this.imgCategorySufix);n = $('wdwCategoryLst').appendChild(newMenu);var funcAddEvent = function(a, n, imgName, id, firstProdId){addEvent(a, 'click', function(){HomeWindow._changeCategory(n, imgName, id, firstProdId);});};funcAddEvent(a, n, arr[i].img, arr[i].id, arr[i].firstProdId);if(this.arrCategories.initialCategory){for(var j=0; j<arr.length; j++){if(arr[j].id == this.arrCategories.initialCategory){initCat = j;}}} else {initCat = 0;}if(i == initCat) this._changeCategory(n, arr[i].img, arr[i].id, arr[i].firstProdId);this.arrCategoriesElements.push(n);}},_resetCategories: function(){var elm, imgName, img;for(var i=0; i<this.arrCategoriesElements.length; i++){elm = this.arrCategoriesElements[i];elm.className = 'off';img = gTag('img', elm)[0];imgName = img.src.split('mn_wdw_')[1].split('_')[0];img.src = this.imgCategoryPrefix + imgName + '_off' + this.imgCategorySufix;}},_changeCategory: function($elm, imgName, id, firstProdId){this.idCategoria = id;this.idProd = firstProdId;this._resetCategories();$elm.className = 'on';gTag('img', $elm)[0].src = this.imgCategoryPrefix + imgName + '_on' + this.imgCategorySufix;var ul = gTag('ul', $('wdwCategoryLstProducts'))[0];ul.style.height = '311px';ProductsWindow.delProducts();ProductsWindow.getProducts(id, firstProdId);}};var ProductsWindow = {returnProductsUrl: 'RetornaProdutos.aspx',productNode: null,setaLeft: null,setaRight: null,_hasInit: false,_lastProduct: null,_lastCategory: null,_arrCurrentProducts: null,_currentProd:0,t1: new Tweener(),_defaultWidth: 504,_defaultProductWidth: 168,init: function(){if(!this._hasInit){var li = gTag('li', $('wdwCategoryLstProducts'))[0];this.productNode = (this.productNode == null) ? li.cloneNode(true) : this.productNode; delElm(li);this._hasInit = true;this.setaLeft = gClass('setaLeft','a',$('wdwCategoryLstProducts'))[0];this.setaRight = gClass('setaRight','a',$('wdwCategoryLstProducts'))[0];var _this = this;var addClick = function(elm, func){elm.href = 'javascript:;';addEvent(elm, 'click', function(){func(_this);});};addClick(this.setaRight, this.nextProd);addClick(this.setaLeft, this.prevProd);}},nextProd: function(_this){_this.getProducts(_this._lastCategory, _this._lastProduct, 'right', true); },prevProd: function(_this){_this.getProducts(_this._lastCategory, _this._lastProduct, 'left', true); },_move: function(orientation){var currPos = (!parseInt(this._ul.style.left) ? 0 : parseInt(this._ul.style.left));var newPos;if(orientation == 'right'){newPos = currPos - this._defaultWidth;} else if(orientation == 'left'){newPos = currPos + this._defaultWidth;}this.t1.onComplete = function(obj, end){};this.t1.run(this._ul, newPos, 'left', 'px');},getProducts: function(idCategoria, idProduto, orientation, clickFromSeta){this._lastCategory = idCategoria;var _orientation = orientation || 'none';var _this = this;ajaxRun({parameters:{idCategoria: idCategoria || '',idProduto: idProduto || '',orientation: orientation || 'right'},encrypt: false,url: this.returnProductsUrl,onFinish: function(answer, extra){if(answer[0]){_this._addProducts(answer[1], _orientation);if(clickFromSeta) _this._move(_orientation);} else {alert(answer[1]);}}});},delProducts: function(){this.t1.stop();this._ul = gTag('ul', $('wdwCategoryLstProducts'))[0];this._ul.style.left = '0px';var arrToDelete = [];for(var i=0; i<this._ul.childNodes.length; i++){if(this._ul.childNodes[i].nodeType == 1){arrToDelete.push(this._ul.childNodes[i]);}}for(var i=0; i<arrToDelete.length; i++){delElm(arrToDelete[i]);}this._arrCurrentProducts = [];this._arrowClicked = 0;},_maxHeight: 200,_addProducts: function($obj, orientation){var arrProds = $obj.products;var _this = this;var newProd, n, img, tit, priceFrom, priceTo, div, stamps;for(var i=0; i<arrProds.length; i++){newProd = this.productNode.cloneNode(true);img = gTag('img', gClass('photo', 'p', newProd)[0])[0];tit = gTag('strong', gClass('prodTit', 'p', newProd)[0])[0];priceFrom = gTag('strike', gClass('prodPriceFrom', 'p', newProd)[0])[0];priceTo = gClass('prodPriceTo', 'p', newProd)[0];div = gClass('prodPriceDiv', 'p', newProd)[0];newProd.id = arrProds[i].id;if(arrProds[i].imgPath)img.src = arrProds[i].imgPath;img.width = 120;img.height = 120;img.alt = img.title = unescape(arrProds[i].name);if(arrProds[i].name){tit.innerHTML = unescape(arrProds[i].name);}if(arrProds[i].link){tit.parentNode.href = arrProds[i].link;}if(arrProds[i].priceFrom){sDiv(priceFrom.parentNode);priceFrom.innerHTML = 'R$' + arrProds[i].priceFrom;}else{hDiv(priceFrom.parentNode);}if(arrProds[i].priceTo){sDiv(priceTo);priceTo.innerHTML = 'Por: R$' + arrProds[i].priceTo;}else{hDiv(priceTo);}if(arrProds[i].priceDiv){div.innerHTML = arrProds[i].priceDiv;}stamps = arrProds[i].stamps;if(stamps){for(var j=0; j<stamps.length; j++){createElm(newProd,['p', {'class':'ico'},['img', {alt:unescape(stamps[j].name), title:unescape(stamps[j].name), src:stamps[j].imgPath}]]);}}var addClickToAll = function(elm, link){addEvent(elm, 'click', function(){window.location.href = link;});addEvent(elm, 'mouseover', function(){elm.className += ' on';});addEvent(elm, 'mouseout', function(){elm.className = elm.className.replace(/on/,'');});elm.style.cursor = 'pointer';};addClickToAll(newProd, arrProds[i].link);if(orientation == 'left'){n = this._ul.insertBefore(newProd, this._ul.firstChild);n.style.left = (this.getExtremeLeftElement() - this._defaultProductWidth) + 'px';this.insertBeforeArray(n);} else { n = this._ul.appendChild(newProd);n.style.left = (this.getExtremeRightElement() + this._defaultProductWidth) + 'px';this._arrCurrentProducts.push(n);}if(i == arrProds.length-1) {this._lastProduct = arrProds[i].id; }setTimeout(function(){_this._maxHeight = n.scrollHeight;_this._ul.style.height = (_this._maxHeight + 15) + 'px';},150);}},insertBeforeArray: function(elm){var tmp = [elm];for(var i=0; i<this._arrCurrentProducts.length; i++){tmp.push(this._arrCurrentProducts[i]);}this._arrCurrentProducts = tmp;},getExtremeRightElement: function(){var r = -this._defaultProductWidth;for(var i=0; i<this._arrCurrentProducts.length; i++){if(parseInt(this._arrCurrentProducts[i].style.left) > r) r = parseInt(this._arrCurrentProducts[i].style.left);}return r;},getExtremeLeftElement: function(){var r = 0;for(var i=0; i<this._arrCurrentProducts.length; i++){if(parseInt(this._arrCurrentProducts[i].style.left) < r) r = parseInt(this._arrCurrentProducts[i].style.left);}return r;}};function showInfoSenha(stTexto,elemAl){sDiv('boxInfo');$('boxInfo').style.top=getPos(elemAl.id)[1]+'px';$('boxInfo').style.left=getPos(elemAl.id)[0]+elemAl.offsetWidth+10+'px';$('pInfo').innerHTML=stTexto;};